package com.hualan.sfzyproject.service;

import com.hualan.sfzyproject.domain.Announcement;
import com.hualan.sfzyproject.mapper.AnnouncementMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class AnnouncementService {

    @Autowired
    private AnnouncementMapper announcementMapper;

    //查询所有公告及发布的咨询师
    public List<Announcement> selectAll() {
        return announcementMapper.selectAll();
    }

    //根据咨询师id查询公告
    public List<Announcement> selectByConsultantId(Long consultantId) {
        return announcementMapper.selectByConsultantId(consultantId);
    }

    //添加公告
    public int insert(Announcement announcement) {
        return announcementMapper.insert(announcement);
    }

    //删除公告
    public int delete(Long id) {
        return announcementMapper.deleteByPrimaryKey(id);
    }

    //修改公告
    public int update(Announcement announcement) {
        return announcementMapper.updateByPrimaryKeySelective(announcement);
    }

    //根据id查询公告
    public Announcement selectById(Long id) {
        return announcementMapper.selectByPrimaryKey(id);
    }


}
